$(function() {
	$("#header").load('header.html', function() {
		loadHeader(3)
	});
	$("#footer").load('footer.html', function(data, status, xhr) {});
	$("#tab").load('tab.html', function(data, status, xhr) {});
	
	var _url = decodeURI(window.location.search)
	var condition = _url.split('=')[1]
	$.ajax({
		url: host + '/MtmlAPI/SucessCaseList',
		type: 'post',
		dataType: 'JSON',
		data: {
			types: 0,
			cid: cid,
			mid: 5,
			index: 1,
			size: 100,
			condition: condition
		},

		success: function(res) {
			var obj = res.data.list
			if(res.state) {
				html = ''
				$.each(obj, function(i, item) {
					var docname = item.DocName.length
					docHtml = ''
					if(docname !== 0) {
						docHtml += `<span>医生：</span><span class='case_docname'>${item.DocName}</span>`
					}
					tablist = ''
					var pro = item.Operation.split(",");
//					console.log(pro)
					$.each(pro, function(j, tabs) {
						var tabs  = tabs.replace(/\，/g, "  " )
						tablist += `<li>${tabs}</li>`
					});
//					console.log(tablist)
					html += `
               		<li onclick="location.href='case-detail.html?mid=${item.mid}'">
					<div class="case-item-img">
						<div class="case-item-img-l">
							<div class='case-img' style='background-image:url(${item.skulist[0].img});'></div>	
							<div class='case-state'>BEFORE</div>
						</div>
						<div class="case-item-img-l case-item-img-r">
							<div class='case-state'>AFTER</div>
							<div class='case-img' style='background-image:url(${item.skulist[1].img});'></div>
						</div>
					</div>
					<ul class="case-item-txt">
						<li class='case-do'>
							<div class="case-per">
								<div>姓名：${item.PatientName}</div>
								<div  class='_doc'>${docHtml}</div>
							</div>
						</li>
						<li class='case-do-txt treat'> 
						<div>治疗前:</div>
						<div class='treat-txt'>${item.skulist[0].Describe}</div>
						</li>
						<li class='case-do-txt treat'>
						<div>治疗后:</div>
						<div class='treat-txt'>${item.skulist[1].Describe}</div>
						</li>
						<li class='case-do-txt'>
							<ul class="case-project">${tablist}</ul>
						</li>
					</ul>
				</li>

				`

				});
				$('.case-list').append(html);

			} else {

			}
		},
		error: function() {}
	});

});